<template>
  <VueEcharts class="box" :option="getOption()"></VueEcharts>
</template>

<script setup lang="ts">
import { functions } from "lodash";

const getOption = () => {
  return {
    xAxis: {
      show: false,
      type: "category",
    },
    yAxis: {
      show: false,
    },
    // 系列
    series: {
      type: "bar",
      data: [10, 20, 30, 40, 50, 60, 10, 20, 30, 40, 50, 60],
      //图形样式
      itemStyle: {
        color: function (a: any) {
          let arr = [
            "red",
            "orange",
            "yellow",
            "green",
            "cyan",
            "blue",
            "red",
            "orange",
            "yellow",
            "green",
            "cyan",
            "blue",
          ];
          return arr[a.dataIndex];
        },
      },
    },
    //
    grid: {
      top: 0,
      left: 0,
      right: 0,
      bottom: 0,
      show: true,
      backgroundColor: {
        type: "linear",
        x: 0,
        y: 0,
        x2: 0,
        y2: 1,
        colorStops: [
          {
            offset: 0,
            color: "cyan", // 0% 处的颜色
          },
          {
            offset: 1,
            color: "yellowgreen", // 100% 处的颜色
          },
        ],
        global: false, // 缺省为 false
      },
    },
    //提示框
    tooltip: {
      show: true,
      //控制提示框区域
      confine: "hidden",
      //提示框位置
      position: function (point, params, dom, rect, size) {
        // 固定在顶部
        return [point[0], "10%"];
      },
      //十字指示器
      axisPointer:{
        type:'cross'
      }
    },
  };
};
</script>

<style scoped>
.box {
  height: 100%;
}
</style>